<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>bookStore列表</title>
<%--导入css --%>
<link rel="stylesheet" href="css/main.css" type="text/css" />

</head>

<body class="main">

	<jsp:include page="head.jsp" />
	<jsp:include page="menu_search.jsp" />

	<div id="divpagecontent">
		<table width="100%" border="0" cellspacing="0">
			<tr>

				<td>
					<div style="text-align:right; margin:5px 10px 5px 0px">
						<a href="index.jsp">首页</a>
							<c:if test="${!empty category}">
							&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;${category}
							</c:if>
							
							&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;图书列表
					</div>

					<table cellspacing="0" class="listcontent">
						<tr>
							<td>
								<h1>商品目录</h1>
								<hr />
								<h1>${category}</h1>&nbsp;&nbsp;&nbsp;&nbsp;共${pageBean.totalCount}种商品
								<hr />
								<div style="margin-top:20px; margin-bottom:5px">
									<img src="images/productlist.gif" width="100%" height="38" />
								</div>
								
								
								<table cellspacing="0" class="booklist">
									<tr>
									
									<c:forEach items="${pageBean.list}" var="product" varStatus="st" >
										<td>
											<div class="divbookpic">
												<p>
													<a href="product_info.jsp"><img src="${pageContext.request.contextPath}${product.url}" width="115"
														height="129" border="0" /> </a>
												</p>
											</div>

											<div class="divlisttitle">
												<a href="${pageContext.request.contextPath}/ProductDetailServlet?id=${product.id}">书名:${product.name}<br />售价:${product.price} </a>
											</div>
										</td>
										<c:if test="${st.count%4==0}">
										</tr>
								</table>
								<table cellspacing="0" class="booklist">
									<tr>
										</c:if>
									</c:forEach>
								</tr>
									</table>
								<div class="pagination">
									<ul>
										<c:choose>
											<c:when test="${pageBean.currentPage==1}"><li class="disablepage">上一页 &lt;&lt;</li></c:when>
											<c:otherwise>
											<li class="nextpage"><a href="javascript:void(0)" onclick="fun1(${pageBean.currentPage-1});" >上一页&gt;&gt;</a></li>
											</c:otherwise>
										</c:choose>
										<c:forEach begin="${pageBean.begin}" end="${pageBean.end}" step="1" var="num" >
											<c:choose>
												<c:when test="${pageBean.currentPage==num}"><li class="currentpage">${num}</li></c:when>
												<c:otherwise><li><a href="javascript:void(0)" onclick="fun1(${num});" >${num}</a></li></c:otherwise>
											</c:choose>
										</c:forEach>
										<c:choose>
											<c:when test="${pageBean.currentPage==pageBean.totalPage}"><li class="disablepage">下一页 &lt;&lt;</li></c:when>
											<c:otherwise>
											<li class="nextpage"><a href="javascript:void(0)" onclick="fun1(${pageBean.currentPage+1});" >下一页&gt;&gt;</a></li>
											</c:otherwise>
										</c:choose>
										<li>总页数:${pageBean.totalPage}</li>
									</ul>
								</div>
							</td>
						</tr>
					</table></td>
			</tr>
		</table>
	</div>



	<jsp:include page="foot.jsp" />


</body>
</html>
<script type="text/javascript">
	function fun1(currentPage){
	 //1 找到表单
	 var form = document.form1;
	 //2 找到表单中的隐藏域
	 var currentPageInput = document.form1.currentPage;
	 //3 将隐藏域的值赋值为要翻到的页码
	 currentPageInput.value = currentPage;
	 //4 将表单提交	
	 form.submit();
	}
</script>